<template>
  <div>
    <el-dialog
      title="OperatorDetails"
      :visible.sync="dialogTableVisible"
      width="930px"
    >
      <r-showTable
        title="基础信息"
        :ListCols="baseInfoCols"
        :ListData="info"
        col="2"
      />
      <r-list title="财务信息" :ListCols="financialCols" :ListData="dataInfo" />
      <r-list
        title="运营角色信息"
        :ListCols="operatorInfo"
        :ListData="dataInfo"
      />
      <r-list title="设备信息" :ListCols="deviceInfo" :ListData="dataInfo" />
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialogTableVisible: false,
      info: {},
      dataInfo: {},
      baseInfoCols: [
        /* {
					type: 'image',
					thShow: e => false,
					rowspan: 4,
					prop: 'pic'
				}, */
        {
          label: "OperatorName",
          prop: "name"
        },
        {
          label: "Creation Time",
          prop: "createdTime"
        },
        {
          label: "Operator地址",
          prop: "address"
        },
        {
          label: "上次登录时间",
          prop: "loginTime"
        },
        {
          label: "联系人",
          prop: "contacts"
        },
        {
          label: "账号Status",
          prop: "state",
          itemClass: e => (e.state == 1 ? "primary" : ""),
          formatter: e =>
            e.state == 1 ? "Enable" : e.state == 2 ? "Forbidden" : "--"
        },

        {
          label: "Phone",
          prop: "phone"
        },
        {
          label: "登录账号",
          prop: "account"
        },
        {
          label: "Operator业务",
          prop: "operateHd",
          formatter: e => {
            let text = "";

            if (e.operateHd == 1) {
              text += "换电、";
            }
            if (e.operateCd == 1) {
              text += "充电、";
            }
            if (e.operateZc == 1) {
              text += "租车";
            }

            if (text[text.length - 1] == "、") {
              text = text.substr(0, text.length - 1);
            }

            return text;
          }
        }
      ],
      financialCols: [
        [
          {
            label: "总订单数量",
            prop: "totalCount"
          },
          // {
          // 	label: '充电订单数量',
          // 	prop: 'chrCount'
          // },
          {
            label: "租Battery Swap Orders数量",
            prop: "excCount"
          },
          // {
          // 	label: '租车订单数量',
          // 	prop: 'carCount'
          // },
          {
            label: "Recharge Orders数量",
            prop: "inCount"
          }
        ],
        [
          {
            label: "订单总Money",
            prop: "totalAmount"
          },
          // {
          // 	label: '充电订单总Money',
          // 	prop: 'chrAmount'
          // },
          {
            label: "租Battery Swap Orders总Money",
            prop: "excAmount"
          },
          // {
          // 	label: '租车订单总Money',
          // 	prop: 'carAmount'
          // },
          {
            label: "Recharge Orders总Money",
            prop: "inAmount"
          }
        ],
        [
          {
            label: "订单总收益",
            prop: "totalProfit"
          },
          // {
          // 	label: '充电订单总收益',
          // 	prop: 'chrProfit'
          // },
          {
            label: "租Battery Swap Orders总收益",
            prop: "excProfit"
          },
          // {
          // 	label: '租车订单总收益',
          // 	prop: 'carProfit'
          // },
          {
            label: "Recharge Orders总收益",
            prop: "inProfit"
          }
        ]
      ],
      operatorInfo: [
        [
          {
            label: "Agent数量",
            prop: "agCount"
          },
          {
            label: "Maintenance Personnel数量",
            prop: "merCount"
          },
          {
            label: "站点数量",
            prop: "siteNum"
          },
          {
            label: "User数量",
            prop: "userCount"
          }
        ]
      ],
      deviceInfo: [
        [
          // {
          // 	label: 'Charging Cabinet数量',
          // 	prop: 'chrNum'
          // },
          {
            label: "换电柜数量",
            prop: "excNum"
          },
          // {
          // 	label: '电动车数量',
          // 	prop: 'carNum'
          // },
          {
            label: "Battery数量",
            prop: "btNum"
          }
        ]
      ]
    };
  },
  created() {},
  mounted() {},
  methods: {
    async init(id) {
      if (this.id == id) {
        this.dialogTableVisible = true;
        return false;
      }
      this.id = id;

      var res = await this.apis.operator_detail({
        id: id
      });

      this.dialogTableVisible = true;
      this.info = res.data;
      this.dataInfo = res.data.params;
    }
  }
};
</script>
<style scoped lang="scss"></style>
